home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Programming / LEDA / source / src / window / _panel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-16  |  4.1 KB  |  187 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  3.1c
  4. +
  5. +
  6. +  _panel.c
  7. +
  8. +
  9. +  Copyright (c) 1994  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15. #include <LEDA/window.h>
  16.  
  17.  
  18. //------------------------------------------------------------------------------
  19. //   PANELS
  20. //------------------------------------------------------------------------------
  21.  
  22. void  panel::display(window& W) { display(W,-1,-1); }
  23.  
  24. void  panel::display(window& W, int x, int y)
  25. { LEDA_PANEL::display(x,y, W.xpos(), W.ypos(), W.width(), W.height()); }
  26.  
  27. void panel::display() { display(-1,-1); }
  28.  
  29. void panel::display(int x, int y)
  30. { LEDA_PANEL::display(x,y,0,0,0,0); }
  31.  
  32.  
  33. int  panel::open(window& W) { return open(W,-1,-1); }
  34.  
  35. int  panel::open(window& W, int x, int y)
  36. { return LEDA_PANEL::open(x,y, W.xpos(), W.ypos(), W.width(), W.height()); }
  37.  
  38. int  panel::open() { return open(-1,-1); }
  39.  
  40. int  panel::open(int x, int y)
  41. { return LEDA_PANEL::open(x,y,0,0,0,0); }
  42.  
  43.  
  44.  
  45.  
  46. void panel::text_item(string s)   
  47. { LEDA_PANEL::text_item(s); }
  48.  
  49. void panel::int_item(string s,int& x) 
  50. { LEDA_PANEL::int_item(s,&x);}
  51.  
  52. void panel::int_item(string s,int& x, int l, int h) 
  53. { LEDA_PANEL::slider_item(s,&x,l,h);}
  54.  
  55. void panel::double_item(string s, double& x) 
  56. { LEDA_PANEL::float_item(s,&x);}
  57.  
  58. void panel::real_item(string s, double& x)
  59. { LEDA_PANEL::float_item(s,&x); }
  60.  
  61. void panel::string_item(string label, string& x)
  62. { x = ~x; //disconnect
  63.   LEDA_PANEL::string_item(label,x.access_ptr());
  64.  }
  65.  
  66. void  panel::string_item(string label,string& x,list<string>& L)
  67. { x = x.cstring(); //disconnect
  68.   const char** p = new const char*[L.length()];
  69.   int    i = 0;
  70.   string s;
  71.   forall(s,L) 
  72.      if (s.length() > 0) p[i++] = s;
  73.   LEDA_PANEL::string_menu_item(label,x.access_ptr(),"",i,p); 
  74.   delete p;
  75. }
  76.  
  77.  
  78. void  panel::choice_item(string label,int& x,list<string>& L)
  79. { const char** p = new const char*[L.length()];
  80.   int    i = 0;
  81.   string s;
  82.   forall(s,L) p[i++] = s;
  83.   LEDA_PANEL::choice_item(label,&x,i,p,1,0); 
  84.   delete p;
  85. }
  86.  
  87. void  panel::choice_item(string header,int& x,string s1, string s2)
  88. { const char* p[2];
  89.   p[0] = s1;
  90.   p[1] = s2;
  91.   LEDA_PANEL::choice_item(header,&x,2,p,1,0);
  92.  }
  93.  
  94. void  panel::choice_item(string header,int& x,string s1, string s2, string s3)
  95. { const char* p[3];
  96.   p[0] = s1;
  97.   p[1] = s2;
  98.   p[2] = s3;
  99.   LEDA_PANEL::choice_item(header,&x,3,p,1,0);
  100.  }
  101.  
  102. void  panel::choice_item(string header,int& x,string s1, string s2, string s3, string s4)
  103. { const char* p[4];
  104.   p[0] = s1;
  105.   p[1] = s2;
  106.   p[2] = s3;
  107.   p[3] = s4;
  108.   LEDA_PANEL::choice_item(header,&x,4,p,1,0);
  109.  }
  110.  
  111. void  panel::choice_item(string header,int& x,string s1, string s2, string s3, string s4, string s5)
  112. { const char* p[5];
  113.   p[0] = s1;
  114.   p[1] = s2;
  115.   p[2] = s3;
  116.   p[3] = s4;
  117.   p[4] = s5;
  118.   LEDA_PANEL::choice_item(header,&x,5,p,1,0);
  119.  }
  120.  
  121.  
  122. void panel::int_item(string s,int& x,int low, int high, int step)   
  123. { int n = (high-low)/step +1;
  124.   char** p = new char*[n];
  125.   for(int i = 0; i < n; i++) p[i] = ~string("%d",low+i*step);
  126.   LEDA_PANEL::choice_item(s,&x,n,(const char**)p,step,low);
  127.   for(i = 0; i < n; i++) delete p[i];
  128.   delete p;
  129.  }
  130.  
  131. void panel::bool_item(string s, bool& x)
  132. { LEDA_PANEL::bool_item(s,(char*)&x); }
  133.  
  134.  
  135. void panel::color_item(string s, color& x)
  136. {
  137.   const char* p[8];
  138.   int n = 8;
  139.  
  140.   p[0] = "white";
  141.   p[1] = "black";
  142.   p[2] = "red";
  143.   p[3] = "green";
  144.   p[4] = "blue";
  145.   p[5] = "yellow";
  146.   p[6] = "violet";
  147.   p[7] = "orange";
  148.  
  149.   if (window::screen_depth()==1) 
  150.   { n = 2;
  151.     if (x!=white) x = black;
  152.    }
  153.  
  154.   LEDA_PANEL::choice_item(s,(int*)&x,n,p,1,0);
  155.  
  156.  }
  157.  
  158. void panel::lstyle_item(string s, line_style& x)
  159. { const char* p[3];
  160.  
  161.   p[0] = "solid";
  162.   p[1] = "dashed";
  163.   p[2] = "dotted";
  164.  
  165.   LEDA_PANEL::choice_item(s,(int*)&x,3,p,1,0);
  166.  }
  167.  
  168.  
  169. // buttons:
  170.  
  171. int panel::button(string s)             
  172. { return LEDA_PANEL::button(s); }
  173.  
  174.  
  175. void panel::new_button_line()            
  176. { LEDA_PANEL::button_line(0,0);  }
  177.  
  178. void panel::new_button_line(list<string>& L)
  179. { const char** p = new const char*[L.length()];
  180.   int i=0;
  181.   string s;
  182.   forall(s,L) p[i++] = s;
  183.   LEDA_PANEL::button_line(i,p);
  184.   delete p;
  185.  }
  186.